
var articleList = [];  //文章数据

apiready = function(){
	var type = api.pageParam.type;
	var compounds = api.pageParam.compounds;
	
	$api.byId("title").innerHTML = type;
	
	loadData(compounds, type);
};
	
function loadData(compounds, type) {
	api.showProgress({
        title: '加载中...',
        modal: false
    });
    
    var getUrl =serviceUrl+"/app/notice?compounds=" + compounds + "&type=" + type;
	api.ajax({
        url: getUrl,
        method: 'get',
        cache: false,
        timeout: 20,
        headers: {
            "Content-type": "application/json;charset=UTF-8"
        }
    }, function (ret, err) {
    	 if (ret) {
        	articleList = ret.data;
        	
        	if (articleList.length > 0) {
        		updateUI();
        	}else{
        	    $api.byId("articlelist").innerHTML = '<div class="am-g" style="text-align:center;padding:5px 10px;"><label>暂无此类信息...</label></div>';
      		
      		}
        	
        } else {
            api.alert({msg: err.msg});
        }
        
        
        api.hideProgress();
    });
    
    
}
	
function updateUI() {
	var html = "";
	
	for (var i = 0; i < articleList.length; i++) {
	
		var obj = articleList[i];
		
		if (i % 2 == 0) {
		
			html += "<div class=\"am-u-s-12\">"
		}
		
		html += "<div class=\"am-u-sm-6\" style=\"padding:0px 5px 5px 0px;float:left;\">";
		html += "<div class=\"am-u-sm-12\" onclick='articleshow("+i+")'  style=\"padding:0px\">";
		html += "<img src=\"http://www.72gs.net"+ obj.img +"\" style=\"height: 118px;width: 100%\"/>";
		html += "</div>";
		html += "<div class=\"am-u-sm-12\" style=\"padding:0px;color:#D3381C;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;\">";
		html += obj.title;
		html += "</div>";
		html += "<div class=\"am-u-sm-12\" style=\"padding:0px;font-size:13px;\">";
		html += "时间:" + obj.createTime;
		html += "</div>";
		html += "</div>";
		
		if (i % 2 == 0) {
		
			html += "</div>";
		}
		
	}
	
	$api.byId("articlelist").innerHTML = html;
	
}
	




//文章详情
function articleshow(index){
    openWin('articleinfo',{'article':articleList[index]});
};



